/*
 * @ : Copyright (c) 2021 Phytium Information Technology, Inc. 
 *  
 * SPDX-License-Identifier: Apache-2.0.
 * 
 * @Date: 2021-06-30 16:51:57
 * @LastEditTime: 2021-07-01 11:24:10
 * @Description:  This files is for 
 * 
 * @Modify History: 
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 */
#ifndef BSP_COMMON_TRAP_H
#define BSP_COMMON_TRAP_H
#include "sdkconfig.h"
#include "exception.h"

#ifdef CONFIG_TARGET_ARMV8_AARCH64
void ShowRegister(exception_frame *regs);

/**
 * When comes across an instruction which it cannot handle,
 * it takes the undefined instruction trap.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void SerrHandle(exception_frame *regs);
#endif

#ifdef CONFIG_TARGET_ARMV8_AARCH32
struct ExceptionStack
{
    unsigned long r0;
    unsigned long r1;
    unsigned long r2;
    unsigned long r3;
    unsigned long r4;
    unsigned long r5;
    unsigned long r6;
    unsigned long r7;
    unsigned long r8;
    unsigned long r9;
    unsigned long r10;
    unsigned long fp;
    unsigned long ip;
    unsigned long sp;
    unsigned long lr;
    unsigned long pc;
    unsigned long cpsr;
};
#endif

int InterruptGetIrq(void);
void InterruptAck(int fiq_irq);

void SystemIrqHandler(int ir);
void IrqHandleException(void *value);
void fiq_handle(void);

#endif // !
